package IO流;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class FileCopyTools3 {
    public static void main(String[] args) {
        //基于字符流缓冲流实现文件拷贝
        copeFile("E:\\a.txt","e:/bb.txt");
    }
   public static void copeFile(String src,String des){
       FileReader fr=null;
       BufferedReader bf=null;
       FileWriter fw=null;
       BufferedWriter bw=null;
       try {
           bf=new BufferedReader(new FileReader(src));
           bw=new BufferedWriter(new FileWriter(des));
           String temp= "";
           while((temp=bf.readLine())!=null){
               bw.write(temp);
               bw.newLine();//换行。不换行就追加
           }
           bw.flush();
       }catch (Exception e){
           e.printStackTrace();
       }finally {
           try {
               if(bf!=null)bf.close();
               if(bw!=null)bw.close();
               if (fr!=null)fr.close();
               if(fw!=null)fw.close();
           }catch (Exception e){
               e.printStackTrace();
           }
       }
   }
}
